﻿using Microsoft.EntityFrameworkCore.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace WebApi0001.Domain
{
    public class DbIntializeHelper
    {
        public static void Initilizer()
        {
            using(var db = new Admin4000DbContext())
            {
                 db.Database.EnsureCreated();

                
                
                    var brand = new Brand
                    {
                        BrandName = "水果",
                        Description = "多汁且主要味觉为甜味和酸味，可食用的植物果实。水果不但含有丰富的营养，而且能够促进消化。"
                    };

                    db.Brands.Add(brand);

                    db.SaveChanges();

                    db.Products.AddRange(new Product[]
                    {
                    new Product
                    {
                        ProductName = "柚子",
                        ShortDesc = "是芸香科植物柚的成熟果实",
                        FullDesc = "柚子果实硕大，扁球形或梨形，个体大，水份多，味甜酸，深受人们喜爱。",
                        BrandId = brand.Id
                    },
                    new Product
                    {
                        ProductName = "葡萄",
                        ShortDesc = "葡萄科植物葡萄的果实",
                        FullDesc = "生食或制葡萄干，并酿酒，酿酒后的酒脚可提酒食酸，根和藤药用能止呕、安胎。",
                        BrandId = brand.Id
                    }
                    });

                    db.SaveChanges();
                

                
            }
        }
    }
}
